// 绑定dispatch
// add(参数) => dispatch(add(参数))
function bindActionCreator(actionCreator, dispatch) {
  return (...args) => dispatch(actionCreator(...args));
  // return function () {
  //   return dispatch(actionCreator.apply(this, arguments));
  // };
}
export default function bindActionCreators(actionCreators, dispatch) {
  // let bound = {};
  // Object.keys(actionCreators).forEach(v => {
  //   let creator = creators[v];
  //   bound[v] = bindActionCreator(creator, dispatch);
  // })
  // return bound;

  // 只处理了 actionCreators 是对象时候，函数未处理
  return Object.keys(actionCreators).reduce((lastRes, item) => {
    lastRes[item] = bindActionCreator(actionCreators[item], dispatch);
    return lastRes;
  }, {});
}
